package com.wonder.framework.authorization;


import lombok.Data;

import java.io.Serializable;
import java.util.Locale;

//import com.wonder.app.domain.User;
import com.wonder.common.constants.Constants;
import com.wonder.common.utils.WonderUtil;


@Data
public class TokenUserModel implements Serializable {
    private static final long serialVersionUID = 4903514237492573024L;
    // 加密后的token key
    public static final String TOKEN_KEY = Constants.TOKEN_KEY;
    // Redis 存储的key
    public static final String TOKEN_REDIS = Constants.LOGIN_TOKEN_KEY;
    // 用户号
    private String userNo;
    private Integer userId;
    private String token;
    // 最后访问时间
    private long lastAccessedTime = System.currentTimeMillis();
    // 过期时间
    private long expirationTime;
    // 客户端类型
    private String clienttype;
    // 客户端语言
    private Locale locale;
    // 客户端ip
    private String host;
    // 当前登录用户信息
   // private User user;

    public String getAuthorization() throws Exception {
        return WonderUtil.encryptPassword(userNo+"_"+ token, TOKEN_KEY);
    }

    public TokenUserModel(String userno, String token){
        this.userNo = userno;
        this.token = token;
    }

    public TokenUserModel() {
    }
}
